<?php
declare (strict_types=1);

namespace app\validate\api;

use think\Validate;

/**
 * 原神抽卡分析验证器
 * Class Index
 * @package app\index\validate
 */
class GenshinTeam extends Validate
{
     public static $position_type = [
        "主C",
        "副C",
        "治疗",
        "辅助"
    ];
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'role_id' => 'require',
        'team_id' => 'require',
        'style' => 'require|in:0,1',
        'title' => 'require|length:1,255',
        'description' => 'require|min:10',
        'instance_ids' => 'require|array',
        'uid' => 'require',
        'team' => 'require',
        'id' => 'require|integer',
        'position' => 'require|in:主C,副C,治疗,辅助',
        'weapon' => 'require|integer',
        'artifact' => 'require|array',
        'stats'=>'require',
        'nickname'=>'require',
        'avatar'=>'require',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'role_id.require' => '请选择角色',
        'team_id.require' => '请选择队伍',
        'style.require' => '请选择阵容类型',
        'style.in' => '阵容类型错误',
        'title.require' => '请填写阵容标题',
        'title.length' => '阵容标题不能超过255个字符',
        'description.require' => '请填写阵容描述',
        'instance_ids.require' => '请选择阵容标签',
        'instance_ids.array' => '阵容标签格式错误',
        'uid.require' => '缺少用户信息',
        'team.require' => '缺少组队角色信息',
        'id.require' => '请选择角色',
        'id.integer' => '角色数据错误',
        'position.require' => '请选择角色定位',
        'position.in' => '角色定位数据错误',
        'weapon.require' => '请选择武器',
        'weapon.integer' => '武器数据类型错误',
        'artifact.require' => '请选择圣遗物',
        'artifact.array' => '圣遗物格式错误',
        'stats.require' => '请选择词条',
        'nickname.require' => '请填写昵称',
        'avatar.require' => '请上传头像',
    ];


    protected $scene = [
        'config' => ['role_id'],
        'add' => ['style','title','description','instance_ids','uid','team'],
        'edit' => ['team_id','style','title','description','instance_ids','uid','team'],
        'team' => ['id','position','weapon','artifact','stats'],
        'delete' => ['team_id','uid'],
        'create' => ['uid'],
        'user' => ['uid','nickname','avatar'],

    ];

}
